<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="starmap-assistant.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>starmap-assistant.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'starmap-assistant.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="StarmapAssistant.html">StarmapAssistant</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview">
<span class="reserved">function</span> StarmapAssistant() {
	<span class="comment">/** this is the creator function for your scene assistant object. It will be passed all the
	   additional parameters (after the scene name) that were passed to pushScene. The reference
	   to the scene controller (this.controller) has not be established yet, so any initialization
	   that needs the scene controller should be done in the setup function below. */</span>
}
<span class="comment">/**Sets up the scene for the starmap.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.setup = <span class="reserved">function</span>() {
	<span class="comment">/* this function is for setup tasks that have to happen when the scene is first created */</span>
	<span class="reserved">this</span>.appController = Mojo.Controller.getAppController();
		
	<span class="comment">/* use Mojo.View.render to render view templates and add them to the scene, if needed. */</span>
	
	<span class="comment">/* setup widgets here */</span>
	<span class="reserved">this</span>.controller.setupWidget(Mojo.Menu.commandMenu,
          <span class="reserved">this</span>.lowerMenuAttributes = {},
          <span class="reserved">this</span>.lowerMenuModel = {
		  	  visible: false,
              label: $L(<span class="literal">'Starmap Lower Menu'</span>), 
								items: [{label: $L(<span class="literal">'Find My Sky'</span>), command:<span class="literal">'findme'</span>}, 
										{icon: <span class="literal">'refresh'</span>, command:<span class="literal">'reload'</span>},
										<span class="comment">/*
										{iconPath: 'images/menu-icon-minus.png', command:'zoomout'},
										{iconPath: 'images/menu-icon-plus.png', command:'zoomin'},
										*/</span>
										]
     });
	 
	 <span class="reserved">this</span>.controller.setupWidget(<span class="literal">'location-activity-spinner'</span>, 
	 	<span class="reserved">this</span>.locationSpinnerAttributes = {spinnerSize: Mojo.Widget.spinnerLarge}, {});
		
	<span class="reserved">this</span>.controller.setupWidget(<span class="literal">"skywindow"</span>,
         <span class="reserved">this</span>.skywindowAttributes = {
             url:    <span class="literal">'http://www.bmcstudiosllc.com/starmap/mobileapp_private/skywindow.html?zoom=18'</span>,
             <span class="comment">//virtualpagewidth: this.controller.window.innerWidth,</span>
             <span class="comment">//virtualpageheight: this.controller.window.innerHeight,</span>
			 useMouseEvents: true,
			 showClickedLink: false,
             },
         <span class="reserved">this</span>.skywindowModel = {
             }
	);
	
	<span class="comment">/* add event handlers to listen to events from widgets */</span>
	<span class="reserved">this</span>.handleLoadingProgress = <span class="reserved">this</span>.handleLoadingProgress.bindAsEventListener(<span class="reserved">this</span>);
	<span class="reserved">this</span>.handleLoaded = <span class="reserved">this</span>.handleLoaded.bindAsEventListener(<span class="reserved">this</span>);
	Mojo.Event.listen(<span class="reserved">this</span>.controller.get(<span class="literal">'skywindow'</span>),Mojo.Event.webViewLoadProgress, <span class="reserved">this</span>.handleLoadingProgress);
	Mojo.Event.listen(<span class="reserved">this</span>.controller.get(<span class="literal">'skywindow'</span>),Mojo.Event.webViewLoadStopped, <span class="reserved">this</span>.handleLoaded);
}

<span class="comment">/**Shows sky window
 *
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.activate = <span class="reserved">function</span>(event) {
	<span class="comment">/* put in event handlers here that should only be in effect when this scene is active. For
	   example, key handlers that are observing the document */</span>
	  <span class="reserved">this</span>.controller.setInitialFocusedElement(<span class="reserved">this</span>.controller.get(<span class="literal">'skywindow'</span>));
	  <span class="reserved">this</span>.controller.get(<span class="literal">'location-activity-spinner'</span>).mojo.start()
}

<span class="comment">/** remove any event handlers you added in activate and do any other cleanup that should happen before
	   this scene is popped or another scene is pushed on top */</span>
StarmapAssistant.<span class="reserved">prototype</span>.deactivate = <span class="reserved">function</span>(event) {
	
}
<span class="comment">/** this function should do any cleanup needed before the scene is destroyed as
	   a result of being popped off the scene stack */</span>
StarmapAssistant.<span class="reserved">prototype</span>.cleanup = <span class="reserved">function</span>(event) {
	
}

<span class="comment">/**Shows loading progress*/</span>
StarmapAssistant.<span class="reserved">prototype</span>.handleLoadingProgress = <span class="reserved">function</span>(event) {
	<span class="reserved">this</span>.controller.get(<span class="literal">"mainTitle"</span>).update(<span class="literal">'Loading: '</span> + event.progress + <span class="literal">'%'</span>);
	<span class="comment">/*
	if (event.progress &gt; 5) {
		this.controller.get('skywindow').style.visibility = 'visible';
	}
	*/</span>
}

<span class="comment">/**Updates scene*/</span>
StarmapAssistant.<span class="reserved">prototype</span>.handleLoaded = <span class="reserved">function</span>(event) {
	<span class="reserved">this</span>.controller.get(<span class="literal">'overlay-scrim'</span>).hide();
	<span class="reserved">this</span>.controller.get(<span class="literal">'location-activity-spinner'</span>).mojo.stop();
	<span class="reserved">this</span>.controller.get(<span class="literal">"mainTitle"</span>).update(<span class="literal">'Starmap Mobile: Starmap'</span>);
	<span class="reserved">this</span>.lowerMenuModel.visible = true;
	<span class="reserved">this</span>.controller.modelChanged(<span class="reserved">this</span>.lowerMenuModel);
}

<span class="comment">/*
StarmapAssistant.prototype.zoomIn = function(event) {
	if (this.skywindowZoom &lt; 18) {
		this.skywindowZoom++;
		this.controller.get('skywindow').mojo.openURL('javascript:void(cur_value=' + this.skywindowZoom);
	}
}

StarmapAssistant.prototype.zoomOut = function(event) {
	if (this.skywindowZoom &gt; 1) {
		this.skywindowZoom--;
		this.controller.get('skywindow').mojo.openURL('javascript:void(cur_value=' + this.skywindowZoom);
	}
}
*/</span>

<span class="comment">/**Handles given commands.*/</span>
StarmapAssistant.<span class="reserved">prototype</span>.handleCommand = <span class="reserved">function</span>(event) {
	<span class="reserved">if</span>(event.type == Mojo.Event.command) {
		switch (event.command) {
			case <span class="literal">'findme'</span>:
				<span class="reserved">this</span>.lowerMenuModel.items[0].command = <span class="literal">'disabled'</span>;
				<span class="reserved">this</span>.controller.get(<span class="literal">'overlay-scrim'</span>).show();
				<span class="reserved">this</span>.controller.get(<span class="literal">'location-activity-spinner'</span>).mojo.start();
				<span class="reserved">this</span>.lowerMenuModel.visible = false;
				<span class="reserved">this</span>.controller.modelChanged(<span class="reserved">this</span>.lowerMenuModel);
				<span class="reserved">this</span>.findMeButton();
				break;

			case <span class="literal">'reload'</span>:
				<span class="reserved">this</span>.controller.get(<span class="literal">'skywindow'</span>).mojo.reloadPage();
				break;
				
			<span class="comment">/*
			case 'zoomout':
				this.zoomOut();
				break;
				
			case 'zoomin':
				this.zoomIn();
				break;
			*/</span>
		}
	}
}

<span class="comment">/**   Updates the location for the scene.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.locationCallback = <span class="reserved">function</span>(data) {
	var locationResponse;
	switch (data.errorCode) {
					case 0:
						locationResponse = <span class="literal">"Latitude: "</span> + data.latitude + <span class="literal">"\n"</span> + <span class="literal">"Longitude: "</span> + data.longitude;
						break;
					case 1:
						locationResponse = <span class="literal">"GPS Timeout."</span>;
						break;
					case 2:
						locationResponse = <span class="literal">"Position Unavailable."</span>;
						break;
					case 5:
						locationResponse = <span class="literal">"Location services are turned off."</span>;
						break;					
					default:
						locationResponse = <span class="literal">"Location error: "</span> + data.errorCode;
						break;
				}
				<span class="reserved">this</span>.controller.get(<span class="literal">'overlay-scrim'</span>).hide();
				<span class="reserved">this</span>.controller.get(<span class="literal">'location-activity-spinner'</span>).mojo.stop();
				<span class="reserved">this</span>.lowerMenuModel.visible = true;
				<span class="reserved">this</span>.controller.modelChanged(<span class="reserved">this</span>.lowerMenuModel);
				<span class="reserved">this</span>.controller.showAlertDialog({
				    title: $L(<span class="literal">"Find My Sky Dialog"</span>),
				    message: $L(locationResponse),
					choices:[{label:$L(<span class="literal">'Ok'</span>)}]
				});
				<span class="reserved">if</span> (data.errorCode==0) {
					var locationURL = <span class="reserved">this</span>.getURL(data);
					<span class="reserved">this</span>.controller.get(<span class="literal">'skywindow'</span>).mojo.openURL(locationURL);
				};
				<span class="reserved">this</span>.lowerMenuModel.items[0].command = <span class="literal">'findme'</span>;
}

<span class="comment">/**Queries the palm database for location.*/</span>

StarmapAssistant.<span class="reserved">prototype</span>.findMeButton = <span class="reserved">function</span>(event) {
	<span class="reserved">this</span>.controller.serviceRequest(<span class="literal">'palm://com.palm.location'</span>, {
		method:<span class="literal">"getCurrentPosition"</span>,
		parameters:{accuracy: <span class="literal">'Medium'</span>, maximumAge: 10, responseTime: 1},
		onSuccess: <span class="reserved">function</span>( data ) 
			{
				<span class="reserved">this</span>.locationCallback(data);
			}.bind(<span class="reserved">this</span>),
		onFailure: <span class="reserved">function</span>( data )
			{
				<span class="reserved">this</span>.locationCallback(data);
			}.bind(<span class="reserved">this</span>),
		}
	);
}

<span class="comment">/**URL Functions*/</span>
StarmapAssistant.<span class="reserved">prototype</span>.getURL = <span class="reserved">function</span>(UI){
	var RA = <span class="reserved">this</span>.locateSkyAbove(UI.latitude,UI.longitude);
    var DEC = UI.latitude;
    var url = <span class="literal">"http://www.bmcstudiosllc.com/starmap/mobileapp_private/skywindow.html?"</span>;
    <span class="comment">//if (UI.angle){DEC=this.updateDec(DEC,UI.angle);}</span>
    url=url+<span class="literal">"RA="</span>+RA + <span class="literal">"&amp;DE="</span>+DEC+<span class="literal">"&amp;zoom=8"</span>;
    <span class="reserved">return</span> url;
}

<span class="comment">/** Updates declination due to angle.
 * <span class="attrib">@param</span> declination Current declination.
 * <span class="attrib">@param</span> angle Current angle from horizon.
 * <span class="attrib">@return</span> newDec The new declination based on angle.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.updateDec = <span class="reserved">function</span>(declination, angle){
	<span class="reserved">return</span> (declination-(angle/100));
}

<span class="comment">/** Finds the celestial coordinates for the sky above the user.
 * <span class="attrib">@param</span> latt Current latitude.
 * <span class="attrib">@param</span> lonn Current longitude.
 * <span class="attrib">@return</span> newRA The new right ascension given latitude and longitude.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.locateSkyAbove = <span class="reserved">function</span>(latt, lonn)
{
	var skyLat=latt;
	var skyLon=lonn;
	var time;
	var timeZone;
	<span class="reserved">if</span>(skyLat&amp;&amp;skyLon)
    {
        var lat=parseFloat(skyLat);
        var lon=parseFloat(skyLon);
        var time=new Date();
        var timeZone=parseFloat(time.getTimezoneOffset()/60);
        var newRA=<span class="reserved">this</span>.sidereal_time(time.getYear(),time.getMonth(),time.getDate(),time.getHours(),time.getMinutes(),time.getSeconds(),<span class="literal">'SIDEREAL_LAST'</span>,lon);
        newRA+=timeZone;
        <span class="reserved">if</span>(newRA&lt;0)
            newRA+=24;
        <span class="reserved">else</span> <span class="reserved">if</span>(newRA&gt;=24)
            newRA-=24;

        <span class="reserved">return</span> newRA;
    }
    <span class="reserved">return</span> 0;

}
<span class="comment">/** Finds sidereal time compared to Grenich.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.sidereal_time = <span class="reserved">function</span>(time_now_tm_year,time_now_tm_mon,time_now_tm_day,time_now_tm_hour,time_now_tm_min,time_now_tm_sec,type,longitude)
{
        var JD_J2000,JD_now,JD_diff;
        var gmst,gast,JC,eqtime,last,lmst;
        time_ref_tm_sec=0;
        time_ref_tm_min=0;
        time_ref_tm_hour=12;
        time_ref_tm_day=1;
        time_ref_tm_mon=0;
        time_ref_tm_year=100;
        JD_J2000=<span class="reserved">this</span>.julian_date(time_ref_tm_year,time_ref_tm_mon,time_ref_tm_day,time_ref_tm_hour,time_ref_tm_min,time_ref_tm_sec);
        JD_now=<span class="reserved">this</span>.julian_date(time_now_tm_year,time_now_tm_mon,time_now_tm_day,time_now_tm_hour,time_now_tm_min,time_now_tm_sec);
        JD_diff=JD_now-JD_J2000;
        JC=JD_diff/36525.0;
        gmst=280.46061837+360.98564736629*JD_diff+0.0003887933*Math.pow(JC,2)-Math.pow(JC,3)/38710000.0;
        <span class="reserved">while</span>(gmst&gt;=360.0)
            gmst-=360.0;
        gmst=gmst/15.0;
        <span class="reserved">if</span>(type==<span class="literal">'SIDEREAL_GMST'</span>)
            <span class="reserved">return</span>(gmst);
        var day_of_year=<span class="reserved">this</span>.FDoY(time_now_tm_year,time_now_tm_mon+1,time_now_tm_day);
        eqtime=(-0.49+0.3*day_of_year/365.0+0.07*Math.cos(2.0*6.2831853*(day_of_year-35.0)/365.0))/3600.0;
        gast=gmst+eqtime;
        <span class="reserved">while</span>(gast&gt;24.0)
            gast-=24.0;
        <span class="reserved">if</span>(type==<span class="literal">'SIDEREAL_GAST'</span>)
            <span class="reserved">return</span> gast;
        last=gast+24.0+longitude/15.0;
        <span class="reserved">while</span>(last&gt;24.0)
            last-=24.0;
        <span class="reserved">if</span>(type==<span class="literal">'SIDEREAL_LAST'</span>)
            <span class="reserved">return</span> last;
        lmst=gmst+24.0+longitude/15.0;
        <span class="reserved">while</span>(lmst&gt;24.0)
            lmst-=24.0;
        <span class="reserved">if</span>(type==<span class="literal">'SIDEREAL_LMST'</span>)
            <span class="reserved">return</span> lmst;
        <span class="reserved">return</span> lmst;
    }
    <span class="comment">/** Finds current Julian date for the day.
    * <span class="attrib">@return</span> JD Today's Julian Date
    */</span>
StarmapAssistant.<span class="reserved">prototype</span>.julian_date = <span class="reserved">function</span>(now_time_tm_year,now_time_tm_mon,now_time_tm_day,now_time_tm_hour,now_time_tm_min,now_time_tm_sec)
{
    var year=now_time_tm_year;
    var month=now_time_tm_mon+1;
    var day=now_time_tm_day;
    var UT=now_time_tm_hour+now_time_tm_min/60.0+now_time_tm_sec/3600.0;
    var JD=367*year-<span class="reserved">this</span>.toInt(7.0*(year+<span class="reserved">this</span>.toInt((month+9.0)/12.0))/4.0)-
        <span class="reserved">this</span>.toInt(3.0*(<span class="reserved">this</span>.toInt((year+(month-9.0)/7.0)/100.0)+1.0)/4.0)+
        <span class="reserved">this</span>.toInt(275.0*month/9.0)+day+1721028.5+UT/24.0;
    <span class="reserved">return</span>(JD);
}
<span class="comment">/** Converts input to integer.
 * <span class="attrib">@param</span> nmb Any number.
 * <span class="attrib">@return</span> nmb The given number as an integer.
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.toInt = <span class="reserved">function</span>(nmb)
{
    <span class="reserved">if</span>(nmb&gt;0)
        <span class="reserved">return</span> Math.floor(nmb);
    <span class="reserved">if</span>(nmb&lt;0)
        <span class="reserved">return</span> Math.ceil(nmb);
    <span class="reserved">return</span> nmb;
}
<span class="comment">/** Finds the day of the year
 * <span class="attrib">@param</span> Y year
 * <span class="attrib">@param</span> M month
 * <span class="attrib">@param</span> D day
 * <span class="attrib">@return</span> The day of the year in seconds from the first of the year
 */</span>
StarmapAssistant.<span class="reserved">prototype</span>.FDoY = <span class="reserved">function</span>(Y,M,D)
{
    <span class="reserved">return</span>(Date.UTC(Y,M,D)-Date.UTC(Y,1,1))/86400000+1;
}</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu May  6 17:21:45 2010</div>
</body>
</html>
